let app = require("electron").app
let gulp = require('gulp')
let childprocess = require('child_process')
let defaultTask = "compile"
let gulpFile="D:\\SystemManagem\\LayaProject\\game\\object\\tools\\..\\.laya\\compile.js"
let gulpDir="E:\\Program Files\\LayaAirIDE\\resources\\app\\node_modules\\gulp\\bin\\gulp.js"
let cmd = [`--gulpfile=${gulpFile}`, defaultTask]
let fork1 = childprocess.fork(gulpDir, cmd,{silent: true})
fork1.stdout.on("data", (data) => {
let str = String(data)
console.log(str)
if(str.match(/\s*Error\:/)){app.exit(1);return;}
let isTasksComplete = str.match(/laya\.ide\.complete$/m)
if (isTasksComplete){
app.exit(0)}
})
fork1.stderr.on("data", (err) => {let errStr=String(err);console.log(errStr);if(errStr.indexOf("Circular dependency")<0){app.exit(1)}})
